package com.hmkj.core.service.userFreeze.impl;

import com.hmkj.common.baseMapper.GenericMapper;
import com.hmkj.common.baseMapper.GenericPo;
import com.hmkj.core.exception.BussinessException;
import com.hmkj.core.mapper.userFreeze.UserFreezeMapper;
import com.hmkj.core.po.userFreeze.UserFreeze;
import com.hmkj.core.service.userFreeze.UserFreezeService;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * 冻结功能表业务相关Service接口实现<br>
 *
 * @ClassName: UserFreezeServiceImpl
 * @author lizhijie
 * @date   2018-07-04 04:41:40
 */
@Service
@Scope("prototype")
@Transactional(rollbackFor = Exception.class)
public class UserFreezeServiceImpl implements UserFreezeService {

	@Resource
    private UserFreezeMapper userFreezeMapper;

    @Override
    public GenericMapper<UserFreeze,Integer> _getMapper() {
        return userFreezeMapper;
    }

    @Override
    public void editFreeze(UserFreeze userFreeze) throws Exception{
        UserFreeze freeze = userFreezeMapper.selectOne(new UserFreeze(u->{
             u.setId(userFreeze.getId());
        }));
        if (freeze == null){
            throw new BussinessException("记录不存在");
        }
        freeze.setFreezeTrade(userFreeze.getFreezeTrade());
        freeze.setFreezeCash(userFreeze.getFreezeCash());
        freeze.setFreezeRecharge(userFreeze.getFreezeRecharge());
        freeze.setFreezingLogin(userFreeze.getFreezingLogin());
        userFreezeMapper.updateByPrimaryKeySelective(freeze);
    }
}
